package org.cloud.demo2.controller;

import java.util.concurrent.TimeUnit;

import javax.annotation.Resource;

import org.cloud.demo1.client.client.Demo1TestClient;
import org.cloud.demo2.entity.UserOfDemo2;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试demo1
 * @author wangyuan
 * @since 2019年6月2日 下午8:59:54
 *
 */
@RestController
@RequestMapping(value = "/demo2")
public class Demo2Controller {
	
	@Resource
	private Demo1TestClient demo1TestClient;

	@RequestMapping(value = "/testMethod1", method = RequestMethod.GET)
	public String testMethod1OfDemo2() {
		System.out.println(demo1TestClient.testMethod1OfDemo1());
		return "你成功的调用了Demo2的服务";
	}
	
	@RequestMapping(value = "/testMethod2", method = RequestMethod.GET)
	public UserOfDemo2 testMethod2OfDemo2() {
		System.out.println(demo1TestClient.testMethod2OfDemo1());
		return new UserOfDemo2(2, 22, "222");
	}
	
	@RequestMapping(value = "/testMethod3", method = RequestMethod.GET)
	public UserOfDemo2 testMethod2OfDemo3() throws Exception {
		TimeUnit.SECONDS.sleep(3);
		return new UserOfDemo2(3, 33, "333");
	}
}
